package com.example.springbootth.controller;

import com.example.springbootth.datasource.MyData;
import com.example.springbootth.entity.Book;
import com.example.springbootth.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;

@Controller
@RequestMapping("/book")
public class BookController {
     ArrayList<Book> books= MyData.getData();

     @RequestMapping("/list")
    public String list(Model model, HttpSession session){
         User user = new User("zhangsan","ADMIN");
         session.setAttribute("user",user);
         model.addAttribute("books",books);
         return "books";
     }
}
